package org.example.ims.Repository.Base;

import org.example.ims.Entity.Base.Category;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface CategoryRepository extends JpaRepository<Category, Integer> {
    @Query("SELECT c FROM Category c " +
            "WHERE (:name IS NULL OR c.categoryName = :name)" )
    Page<Category> searchCategories(@Param("name") String name,
                                 Pageable pageable);
}
